package dfl.bysj.controller;


import dfl.bysj.entity.VO.Form_ReserveTime;
import dfl.bysj.entity.VO.Form_value;
import dfl.bysj.result.R;
import dfl.bysj.service.ReserveTimeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author DFL
 * @since 2022-05-17
 */
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/reserveTime")
public class ReserveTimeController {

    private ReserveTimeService reserveTimeService;

    @Autowired
    public void setReserveTimeService(ReserveTimeService reserveTimeService) {
        this.reserveTimeService = reserveTimeService;
    }

    @GetMapping("/list")
    public R list(){
        return R.ok().data("list",reserveTimeService.getAllReserveTime());
    }

    @GetMapping("/id")
    public R id(@PathVariable String id){
        return R.ok().data("reserveTime",reserveTimeService.getById(Integer.parseInt(id)));
    }

    @PostMapping(value = "/insert", produces = "application/json;charset=UTF-8")
    public R insert(@RequestBody Form_ReserveTime form_reserveTime) {
        log.info(form_reserveTime.toString());
        reserveTimeService.updateReserveTime(form_reserveTime);
        return R.ok();
    }
}

